using System;
using System.Collections.Generic;

namespace MoveModel
{
	public class Stroke : List<Shape>
	{
        protected int circleVertives { get; set; }
		public int shapeInt;
		protected int color;
        public int Color
        {
            get { return color % 5; }
            set { color = value % 5; }
        }
        protected static bool wireMode = false;
        public static bool PolygonMode
        {
            get { return wireMode; }
            set { wireMode = value; }
        }
        

        /// <summary>
        /// 
        /// </summary>
        /// <param name="shape">0 - shere (default), 1 - cube</param>
        /// <param name="color">One of 5 different colors (default 0)</param>
        /// <param name="gradeOfDetail">The higher the number the more detailed is the shape. Default = 25</param>
		public Stroke (int shape = 0, int color = 0, int gradeOfDetail = 25)
            : base()
		{
			this.shapeInt = shape;
			this.color = color;
            this.circleVertives = gradeOfDetail;
		}

        /// <summary>
        /// 
        /// </summary>
        /// <param name="s">new Shape</param>
        public void AddShape(Shape s)
        {
            if(this.Count == 0)
                base.Add(s);
            else
            {   
                //ps = previous shape
                Shape ps = this[Count - 1];

                double distance = Math.Sqrt(
                    Math.Pow(s.x - ps.x,2) +
                    Math.Pow(s.y - ps.y,2) +
                    Math.Pow(s.z - ps.y,2)
                    );
                if (distance > ps.radius + s.radius)
                    base.Add(s);
            }
        }

        
        public Shape Last
        {
            get {
                return this[Count - 1];
            }
        }

        //Helper method
        protected double[,] To2DArray(List<double[]> source)
        {
            double[,] arr = new double[source.Count, source[0].Length];
            for (int i = 0; i < source.Count; i++)
            {
                for (int j = 0; j < source[0].Length; j++)
                {
                    arr[i, j] = source[i][j];
                }
            }
            return arr;
        }
	}
}

